
*********************************************
***** Figure H.5: Other Electonic payment
*********************************************

import delimited "$datadir\banking\POSdatabybanks.csv", clear
	replace bank = trim(bank)
	collapse (sum) atm* pos* no* cc* dc*, by(time)
	egen time_id = group(time)
	gen x = time_id if time == 201610
	egen x1 = max(x)
	replace time_id = time_id - x1
	drop x x1 time

	lab var cc_trans_pos_no "Credit Cards (#Trans at Sale Point)"
	lab var dc_trans_pos_no "Debit Cards (#Trans at Sale Point)"
	lab var cc_trans_pos_amt "Credit Cards (Amount at Sale Point)"
	lab var dc_trans_pos_amt "Debit Cards (Amount at Sale Point)"
	lab var cc_trans_atm_no "Credit Cards (#Trans at ATM)"
	lab var dc_trans_atm_no "Debit Cards (#Trans at ATM)"
	lab var cc_trans_atm_amt "Credit Cards (Amount at ATM)"
	lab var dc_trans_atm_amt "Debit Cards (Amount at ATM)"	
	lab var no_creditcards "# Credit Cards"
	lab var no_debitcards  "# Debit Cards"
	
	local graphs ""
	local i = 0
	sort time_id
	local textsize medsmall
	foreach var in  dc_trans_atm_no dc_trans_atm_amt cc_trans_pos_no dc_trans_pos_no {
		local i = `i'+1
		g change`var' = (`var'-`var'[_n-1])/`var'[_n-1]
		twoway connected change`var' time_id if time_id > -7, title(`: variable label `var'',size(`textsize')) xline(2, lwidth(14) lc(gs12)) ytitle(% change) xtitle(Months after shock) xline(0.5, lpat(shortdash)) lcolor(gray) mcolor(black) ylab(-0.75(0.25)0.75, nogrid) xlab(-5(2)8) graphregion(color(white)) xlabel(,labsize(`textsize')) ylabel(,labsize(`textsize')) name(g`i',replace) nodraw
		local graphs "`graphs' g`i'"
		drop change
	}
	
graph combine `graphs', col(2) graphregion(color(white))
graph export "$outputdir_fig\Figure_H_5_1.pdf", as(pdf) replace
	
	*** Change in CC, Debit Cards (aggregate)
	local graphs ""
	local i = 0
	sort time_id
	local textsize medsmall
	foreach var in no_creditcards  no_debitcards{
		local i = `i'+1
		cap drop change
		g change = (`var'-`var'[_n-1])/`var'[_n-1]
		twoway connected change time_id if time_id > -7 & time_id < 8, title(`: variable label `var'',size(`textsize')) xline(2, lwidth(14) lc(gs12)) ytitle(% change) xtitle(Months after shock)  xline(0.5, lpat(shortdash)) lcolor(gray) mcolor(black) ylab(-0.05(0.05)0.1, nogrid) xlab(-5(2)8) graphregion(color(white)) xlabel(,labsize(`textsize')) ylabel(,labsize(`textsize')) name(g`i',replace) nodraw
		local graphs "`graphs' g`i'"
		drop change
	}
	
graph combine `graphs', ycommon col(2) graphregion(color(white))
graph export "$outputdir_fig\Figure_H_5_2.pdf", as(pdf) replace

